<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class UserInfo extends CI_Controller {

	function __construct(){
		log_message(ETS_INFO, '### C:/admin/UserInfo->construct');
		parent::__construct();
		$this->load->library('mylang');
		$this->mylang->load('admin');
		$this->load->library ('mysession');
		$this->load->model('data_model');
	}
	
	public function index()
	{
		log_message(ETS_INFO, '### C:/admin/UserInfo->index()');
		log_message(ETS_INFO, '### goto V:/userinfo.php');
		/*
		 * 获取登陆用户信息
		*/
		$userID = $this->mysession->getUserID();
		
		$userData = $this->data_model->getSingle(array('id'=>$userID),'tb_user');
		
		$data = array('userData'=> $userData );
		$this->load->view('admin/userinfo',$data);
	}
	
	public function save(){
		
		$post = $this->input->post(NULL,TRUE);		
		$data = array(
				'realname'=>trim($post['realname']),
				'tel'=>trim($post['tel']),
				'address'=>trim($post['address']),
				'updatetime'=>time(),
				'lastip'=>$this->input->ip_address()
		);
		//file_put_contents("test.txt", $data);
		$this->data_model->editData(array('id'=>$this->mysession->getUserID()),$data,'tb_user');
		show_jsonmsg(array('status'=>205));
	}
}
